/**
 * Created by nena on 2018/11/1.
 */


process.env.NODE_ENV = 'dev'
let config = require("./config");

console.log(config.host, config.redisPort, config.redisAuth);

let dao = require('./server/dao')
dao.initRedis(config.host, config.redisPort, config.redisAuth)


let acdManager = require('./server/acdManager');

let domain = ":syy:test"

let g = ['g0', 'g1']
let a = ['a0', 'a1', 'a2', 'a3']
let a1 = ['a0', 'a1', 'a2']
let a2 = ['a0', 'a1', 'a2', 'a3']
let a3 = ['a3', 'a4']
let r = ['r0', 'r1', 'r2', 'r3', 'r4', 'r5', 'r6']

var v = -1
if (v === 0) {
    /*acdManager.onlineAgent(domain, a[0], g, (e, v) => {
        console.log("onlineAgent", v)
        console.log("................")
    })*/

    /*acdManager.addGroup(domain, g[0], a1, (e, v) => {
        console.log("addGroup1", v)
    })*/

    /*acdManager.addGroup(domain, g[0], [], (e, v) => {
        console.log("addGroup1", v)
    })*/

    /*acdManager.onlineAgent(domain, a[0], [], (e, v) => {
        console.log("onlineAgent", v)
        console.log("................")
    })*/

    /*acdManager.onlineAgent(domain, a[0], [], (e, v) => {
        console.log("onlineAgent", v)
        console.log("................")
        acdManager.addGroup(domain, g[0], a1, (e, v) => {
            console.log("addGroup1", v)
        })
    })*/

    /*acdManager.addGroup(domain, g[0], a1, (e, v) => {
        console.log("addGroup1", v)
        acdManager.onlineAgent(domain, a[0], g, (e, v) => {
            console.log("onlineAgent", v)
            console.log("................")
        })
    })*/
}


var y = -1
if (y === 0) {
    /*acdManager.addRequest(domain, r[3], g[0], null, false, (e, v) => {
        console.log("addRequest", v)
        console.log("................")
    })*/

    /*acdManager.addRequest(domain, r[2], g[0], null, false, (e, v) => {
        console.log("addRequest", v)
        console.log("................")
        acdManager.deleteRequest(domain, r[2], g[0], (e, v) => {
            console.log("deleteRequest", v)
            console.log("................")
        })
    })*/

    /*acdManager.takeRequest(domain, a[1], (e, v) => {
        console.log("takeRequest", v)
        console.log("................")
    })*/

    /*acdManager.takeRequest(domain, a[0], (e, v) => {
        console.log("takeRequest", v)
        console.log("................")
    })*/

    /*acdManager.addRequest(domain, r[4], g[0], null, false, (e, v) => {
        console.log("addRequest", v)
        console.log("................")
        acdManager.addRequest(domain, r[0], g[0], null, false, (e, v) => {
            console.log("addRequest", v)
            console.log("................")
            acdManager.takeRequest(domain, a[1], (e, v) => {
                console.log("takeRequest", v)
                console.log("................")
            })
            acdManager.takeRequest(domain, a[0], (e, v) => {
                console.log("takeRequest", v)
                console.log("................")
            })
        })
    })*/

    /*acdManager.deleteRequest(domain, r[4], g[0], (e, v) => {
        console.log("deleteRequest", v)
        console.log("................")
    })*/

    /*acdManager.onlineAgent(domain, a[1], g, (e, v) => {
        console.log("onlineAgent", v)
        console.log("................")
        acdManager.takeRequest(domain, a[1], (e, v) => {
            console.log("takeRequest", v)
            console.log("................")
        })
    })*/

    /*acdManager.takeRequest(domain, a[1], (e, v) => {
        console.log("takeRequest", v)
        console.log("................")
    })*/

}

var z = 0
if (z === 0) {
    /*acdManager.updateAgent(domain, a[0], [], (e, v) => {
        console.log("updateAgent", v)
        console.log("................")
    })*/

    /*acdManager.updateAgent(domain, a[1], [g[1]], (e, v) => {
        console.log("updateAgent", v)
        console.log("................")
    })*/

/*    acdManager.updateAgent(domain, a[0], g, (e, v) => {
        console.log("updateAgent", v)
        console.log("................")
    })*/

/*    acdManager.addRequest(domain, r[3], g[0], null, false, (e, v) => {
        console.log("addRequest", v)
        console.log("................")
        acdManager.addRequest(domain, r[2], g[0], null, false, (e, v) => {
            console.log("addRequest", v)
            console.log("................")
            acdManager.addRequest(domain, r[1], g[0], null, false, (e, v) => {
                console.log("addRequest", v)
                console.log("................")
                acdManager.updateAgent(domain, a[0], [], (e, v) => {
                    console.log("updateAgent", v)
                    console.log("................")
                })
            })
        })
    })*/


/*    acdManager.addRequest(domain, r[3], g[1], null, false, (e, v) => {
        console.log("addRequest", v)
        console.log("................")
        acdManager.addRequest(domain, r[2], g[1], null, false, (e, v) => {
            console.log("addRequest", v)
            console.log("................")
            acdManager.addRequest(domain, r[1], g[1], null, false, (e, v) => {
                console.log("addRequest", v)
                console.log("................")
                acdManager.updateGroup(domain, g[1], [], [a[1]], (e, v) => {
                    console.log("updateGroup", v)
                    console.log("................")
                })
            })
        })
    })*/
}


// var s = 0
let ss = function (){
    /*acdManager.onlineAgent(domain, a[0], [g[0]]).then(v => {
        console.log("onlineAgent", v)
        console.log("................")
        acdManager.onlineAgent(domain, a[1], [g[0]]).then(v => {
            console.log("onlineAgent", v)
            console.log("................")
            acdManager.onlineAgent(domain, a[2], [g[0]]).then(v => {
                console.log("onlineAgent", v)
                console.log("................")
            })
        })
    })*/

    /*acdManager.addRequest(domain, r[0], g[0], null, false).then(v => {
        console.log("addRequest 0", v)
        console.log("................")
    })*/
    /*acdManager.deleteRequest(domain, r[0], g[0], a[0]).then(v => {
        console.log("deleteRequest", v)
        console.log("................")
    })*/

    /*acdManager.addRequest(domain, r[1], g[0], null, false).then(v => {
        console.log("addRequest 1", v)
        console.log("................")
    })*/
    /*acdManager.deleteRequest(domain, r[1], g[0], a[1]).then(v => {
        console.log("deleteRequest", v)
        console.log("................")
    })*/

    /*acdManager.addRequest(domain, r[2], g[0], null, false).then(v => {
        console.log("addRequest 2", v)
        console.log("................")
    })*/
    /*acdManager.deleteRequest(domain, r[2], g[0], a[2]).then(v => {
        console.log("deleteRequest", v)
        console.log("................")
    })*/

    /*acdManager.addRequest(domain, r[2], g[0], null, false, (e, v) => {
        console.log("addRequest 2", v)
        console.log("................")
    })*/
    /*acdManager.addRequest(domain, r[3], g[0], null, false, (e, v) => {
        console.log("addRequest 3", v)
        console.log("................")
    })*/

    /*acdManager.takeRequest(domain, a[0], (e, v) => {
        console.log("takeRequest", v)
        console.log("................")
    })
    acdManager.takeRequest(domain, a[0], (e, v) => {
        console.log("takeRequest", v)
        console.log("................")
    })*/

}
ss()




/*require('seneca')()
    .use(require('./plugin/acdmodel')).listen(config.serverPort)

let acdServer = require('seneca')().client(config.serverPort);

acdServer.act({cmd: 'addGroup', domain: "a", id: "111", agents: ""}, function (err, result) {
    console.log('addGroup: ', result);
});

acdServer.act({cmd: 'onlineAgent', domain: "a", agentId: "111", groups: ''}, function (err, result) {
    console.log('addGroup: ', result);
});

dao.getAgentStatus("a", "254654").then(v => {
    console.log("~~~~~~~~getAgentStatus:", v)
})*/


/*
let {mapSeries} = require("async")
mapSeries(undefined, function (item, cb) {
    cb()
}, function (err, rst) {
    console.log("done:", err, rst)
})*/
